package sink;

import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.junit.Test;

import java.util.Properties;

public class Flink_sink_Kafka {
    @Test
    public void test() throws Exception {
        Properties properties = new Properties();
        properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,"node193:9092");
        properties.put(ProducerConfig.ACKS_CONFIG,"-1");

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment().setParallelism(1);

        env.socketTextStream("node193",9999)
                .addSink(new FlinkKafkaProducer<String>("topicname",new SimpleStringSchema(),properties));

        env.execute();
    }
}
